package fr.afcepf.ai89.esharing.data;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import fr.afcepf.ai89.esharing.entity.FrCommune;
import fr.afcepf.ai89.esharing.entity.FrCommunePK;
import fr.afcepf.ai89.esharing.entity.FrDepartement;
import fr.afcepf.ai89.esharing.entity.FrRegion;

@Stateless
public class DAOFrCommune implements IDAOFrCommune {

	@PersistenceContext(unitName = "ESharingPhase22")
	EntityManager em;

	@Override
	public FrCommune getCommune(FrCommunePK idCommune) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FrCommune> getCommunes() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FrCommune> getCommunes(FrRegion region) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<FrCommune> getCommunes(FrDepartement dept) {
		
		Query hql = em.createQuery("SELECT c from FrCommune c WHERE c.id.idDepartement = :param");

		hql.setParameter("param", dept.getIdDepartement());
		List<FrCommune> communes = (List<FrCommune>)hql.getResultList();

		return communes;
		
	}

	@Override
	public int addCommune(FrCommune commune) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int majCommune(FrCommune commune) {
		// TODO Auto-generated method stub
		return 0;
	}

}
